import React from 'react';
import { Card, Form, Input, Upload, Button, Space, Breadcrumb, message } from 'antd';
import { HomeOutlined, UploadOutlined } from '@ant-design/icons';
import { Link, useParams, useNavigate } from 'react-router-dom';
import MainLayout from '../../components/MainLayout';
import styles from './ReformResult.module.less';

const { TextArea } = Input;

const ReformResult: React.FC = () => {
  const { id } = useParams();
  const navigate = useNavigate();
  const [form] = Form.useForm();

  const handleSubmit = async (values: any) => {
    try {
      // TODO: 调用API提交复查结果
      message.success('提交成功！');
      navigate('/formal-acceptance/reform');
    } catch (error) {
      message.error('提交失败，请重试！');
    }
  };

  return (
    <MainLayout>
      <div className={styles.breadcrumb}>
        <Breadcrumb items={[
          {
            title: <Link to="/home"><HomeOutlined /> 首页</Link>,
          },
          {
            title: <Link to="/formal-acceptance/reform">整改复查</Link>,
          },
          {
            title: '提交复查结果',
          }
        ]} />
      </div>

      <Card title="复查结果" className={styles.formCard}>
        <Form
          form={form}
          layout="vertical"
          onFinish={handleSubmit}
        >
          <Form.Item
            label="复查申明"
            name="description"
            rules={[{ required: true, message: '请输入复查申明' }]}
          >
            <TextArea rows={6} placeholder="请详细描述复查情况..." />
          </Form.Item>

          <Form.Item
            label="复查材料"
            name="attachments"
            rules={[{ required: true, message: '请上传复查材料' }]}
          >
            <Upload
              multiple
              listType="text"
              action="/api/upload"
              beforeUpload={(file) => {
                const isValidSize = file.size / 1024 / 1024 < 50;
                if (!isValidSize) {
                  message.error('文件大小不能超过50MB！');
                }
                return isValidSize;
              }}
            >
              <Button icon={<UploadOutlined />}>上传文件</Button>
            </Upload>
          </Form.Item>

          <Form.Item className={styles.formFooter}>
            <Space>
              <Button onClick={() => navigate(-1)}>取消</Button>
              <Button type="primary" htmlType="submit">提交</Button>
            </Space>
          </Form.Item>
        </Form>
      </Card>
    </MainLayout>
  );
};

export default ReformResult; 